<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="text" placeholder="输入" v-model="inputV" @keyup.enter="add">
        <br>
        <div v-for="(item,index) in list">
            <span>{{index+1}}</span>--------<span>{{item}}</span> <span @click="del(index)">X</span>
        </div>
        <br>
        <span v-show="list.length!= 0">{{list.length}}</span>------<span v-show="list.length!= 0"
            @click=" qko">清空</span>


    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                list: ["吃饭", "睡觉"],
                inputV: "好好学习"
            },
            methods: {
                add() {
                    this.list.push(this.inputV)
                },
                del(index) {
                    this.list.splice(index, 1)
                },
                qko() {
                    this.list = []
                }
            }
        })
    </script>
</body>

</html>